//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_DOMAIN_COMPILING_SQL_VARIABLEGATHER_H
#define NATIVE_DOMAIN_COMPILING_SQL_VARIABLEGATHER_H

#ifndef NATIVE_DOMAIN_COMPILING_COMMON_GATHER_H
#include "Domain/Compiling/Common/Gather.h"
#endif
#ifndef NATIVE_DOMAIN_COMPILING_COMMON_OBSERVE_H
#include "Domain/Compiling/Common/Observe.h"
#endif
#ifndef NATIVE_DOMAIN_COMPILING_SQL_VARIABLE_H
#include "Domain/Compiling/Sql/Variable.h"
#endif

namespace Native { namespace Compiling { namespace Sql
{
    const static wstring VARABLE_GATHER_NAME_KEY = L"Name";
    const static wstring VARABLE_GATHER_TYPE_KEY = L"Type";
    const static wstring VARABLE_GATHER_VALUE_KEY = L"Value";
    const static wstring VARABLE_GATHER_OUTPUT_KEY = L"OUtput";

    //****************************************************************************************************************//
    //CVariableGather
    //
    //****************************************************************************************************************//
    NATIVE_DECLARE_CONST_OBJECT(CVariableGather, C_VARIABLE_GATHER);
    class NATIVE_LIBRARY_EXPORT CVariableGather :
        public CGather,
        public ICast<CVariable>
    {
        NATIVE_DECLARE_OBJECT;

    protected:
        CArray<IObserve<CVariable>*> _obsevers;

    public:
        CVariableGather();
        CVariableGather(C_VARIABLE_GATHER& that);
        CVariableGather(C_VARIABLE_GATHER&& that);
        virtual ~CVariableGather();
        //{CGather
        virtual void Update() const throw();
        //}
        //{ICast
        virtual CVariable Cast() const throw();
        //}
        void Register(IObserve<CVariable>* obsever) throw();
        void CollectName(C_STRING& name) throw();
        void CollectType(C_STRING& type) throw();
        void CollectValue(C_STRING& value) throw();
        void CollectOutput(bool output) throw();

        C_VARIABLE_GATHER& operator=(C_VARIABLE_GATHER& rvalue);
    };
}}}

#endif
